<?php

class openapi_api_params_v1_cart extends openapi_api_params_abstract implements openapi_api_params_interface{

    public function checkParams($method,$params,&$sub_msg,$defined_params=array(),$dataType='kv'){
        if(parent::checkParams($method,$params,$sub_msg,$defined_params,$dataType)){
            return true;
        }else{
            return false;
        }
    }

    public function getAppParams($method){
        $params = array(
            'add'=>array(
                'login_token'=>array('required'=>'true','type'=>'string','name'=>'登录token'),
                'goods_id'=>array('required'=>'true','type'=>'int','name'=>'商品ID'),
                'product_id'=>array('required'=>'true','type'=>'int','name'=>'货品ID'),
                'num'=>array('required'=>'true','type'=>'int','name'=>'订货量'),
                'pmt_id'=>array('required'=>'false','type'=>'int','name'=>'配件ID'),
                'cart_type'=>array('required'=>'false','type'=>'string','name'=>'购物车对象类型'),
                'ass_store_id'=>array('required'=>'false','type'=>'string','name'=>'关联经销商ID'),
            ),
            'useCoupons'=>array(
                'login_token'=>array('required'=>'true','type'=>'string','name'=>'登录token'),
                'coupon'=>array('required'=>'false','type'=>'string','name'=>'优惠码'),
                'split_order'=>array('required'=>'true','type'=>'string','name'=>'分单数据'),
                'isdel'=>array('required'=>'false','type'=>'int','name'=>'是否取消使用'),
                'area'=>array('required'=>'false','type'=>'string','name'=>'选择的区域'),
            ),
            'addList'=>array(
                'login_token'=>array('required'=>'true','type'=>'string','name'=>'登录token'),
                'content'=>array('required'=>'true','type'=>'json','name'=>'购物对象',
                    'cols'=>array('required'=>'true','type'=>'json','name'=>'购物对象',
                        'items'=>array(
                            'goods_id'=>array('required'=>'true','type'=>'int','name'=>'商品ID'),
                            'num'=>array('required'=>'true','type'=>'int','name'=>'订货量'),
                            'product_id'=>array('required'=>'true','type'=>'int','name'=>'货品ID'),
                            'pmt_id'=>array('required'=>'false','type'=>'int','name'=>'配件ID'),
                        ),
                    ),
                ),
            ),
            'cartlist'=>array(
                'login_token'=>array('required'=>'true','type'=>'string','name'=>'登录token'),
            ),
            'deletecart'=>array(
                'login_token' => array('required'=>'true','type'=>'string','name'=>'登录token'),
                'delcarts'=>array('required'=>'true','type'=>'json','name'=>'购物车对象',
                    'cols'=>array(
                        'items'=>array(
                            'obj_ident'=>array('required'=>'true','type'=>'string','name'=>'商品标识'),
                            'obj_type'=>array('required'=>'true','type'=>'string','name'=>'对象类型'),
                        ),
                    ),
                ),
            ),
            'updatenums'=>array(
                'login_token' => array('required'=>'true','type'=>'string','name'=>'登录token'),
                'obj_ident' => array('required'=>'true','type'=>'string','name'=>'货品标识'),
                'quantity' => array('required'=>'true','type'=>'int','name'=>'数量'),
            ),
            'checkout'=>array(
                'login_token' => array('required'=>'true','type'=>'string','name'=>'登录token'),
                'content'=>array('required'=>'true','name'=>'订单数组','type'=>'json',
                    'cols'=>array(
                        'items'=>array(
                            'obj_ident' => array('required'=>'true', 'type'=>'string','name'=>'商品ident'),
                            'quantity'  => array('required'=>'true',  'type'=>'int','name'=>'此商品数量'),
                        ),
                    ),
                ),
            ),
            'updateactmember'=>array(
                'member_id'   => array('required'=>'true','type' => 'int','name' => '用户id'),
                'name'   => array('required'=>'true','type' => 'string','name' => '收货人'),
                'area'   => array('required'=>'true','type' => 'string','name' => '收货地区'),
                'addr'   => array('required'=>'true','type' => 'string','name' => '收货地址'),
                'zip'   => array('type' => 'string','name' => '邮编'),
                'tel'   => array('type' => 'string','name' => '电话'),
                'mobile'   => array('type' => 'string','name' => '手机'),
                'addr_id'   => array('type' => 'int','name' => '需修改的收货信息id'),           
            ),
            'payment'=>array(
                'randnum'   => array('required'=>'true','type' => 'string','name' => '任意参数'),
            ),
            'auto_generation_order'=>array(
                'login_token' => array('required'=>'true','type'=>'string','name'=>'登录token'),
                'order_id' => array('required'=>'true','type'=>'string','name'=>'订单ID'),
            ),
        );

        return $params[$method];
    }

    public function description($method){
        $desccription = array(
            'add'=>array(
                'name'        =>'添加到购物车',
                'description' =>'添加到购物车',
            ),
            'useCoupons'=>array(
                'name'        =>'添加优惠券',
                'description' =>'添加优惠券',
            ),
            'addList'=>array(
                'name'        =>'批量添加到购物车',
                'description' =>'批量添加到购物车',
            ),
            'cartlist'=>array(
                'name'        =>'购物车商品列表',
                'description' =>'购物车商品列表',
            ),
            'deletecart'=>array(
                'name'        =>'删除购物车',
                'description' =>'删除购物车',
            ),
            'checkout'=>array(
                'name'        =>'结算检查',
                'description' =>'结算检查,act_id为数组,num为数组和act_id值对应',
            ),
            'auto_generation_order'=>array(
                'name'        =>'自动生成订单',
                'description' =>'活动订单上浮',
            ),
        );
        return $desccription[$method];
    }

}